<%@ page pageEncoding="UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="flexible" content="initial-dpr=2,maximum-dpr=3" />
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
    <title>创新通登录</title>
    <link rel="stylesheet" href="../static/app/style/index.css"/>
</head>
<style>
.xn-login-index .wrap-btn1 {
    display: block;
    width: 9.6rem;
    margin: 0.2rem auto 0.2rem auto;
}
</style>
<body>
<div class="xn-login-index" style="overflow-y:hidden">
    <div class="nav-title">
        <span class="content">创新通登录</span>
    </div>
    <form class="form-horizontal" method="post" id="loginForm">
        <div class="wrap-input" style="margin-top: 1.76rem;">
	        <div class="iptItem accountItem borderBt">
	        	<span class="icon"></span>
	        	<input type="text" class="account inputBox" name="userAccount" id="userAccount" placeholder="请输入账号"/>
	        </div>
	        <div class="iptItem pwdItem">
	        	<span class="icon"></span>
	        	<input type="password" class="password inputBox" name="userpass" id="userpass" placeholder="请输入密码"/>
	        </div>
    	</div>
    	<div class="wrap-btn1 clearfix" style="height:30px;text-align:right">
	        <span style="line-height:30px;vertical-align:bottom;">是否记住密码</span>
			<input class="mui-switch mui-switch-anim"name="rememberName" type="checkbox" id="rememberName">
		</div>
    	<div class="wrap-btn1 clearfix">
        	<a href="#" class="f-left loginBtn defaultBtn" onclick="saveName()">登录</a>
        	<a href="#" class="f-right resetBtn defaultBtn" onclick="clearAll()">重设</a>
    	</div>
    </form>
</div>

<script type="text/javascript" src="../static/app/js/jQuery-2.1.4.min.js"></script>
<script type="text/javascript" src="../static/app/js/resize.js"></script>
<script type="text/javascript" src="../static/app/js/base.js"></script>
<script type="text/javascript" src="../static/app/js/page/loginIndex.js"></script>
<script type="text/javascript" src='${pageContext.request.contextPath}/static/js/jquery.cookie.js'></script>
<script type="text/javascript">
$(function() {
	$("#userAccount").val($.cookie("userAccount"));
	$(document).keypress(function(e) {
	       if(e.which == 13) {
	    	   saveName();
	       }
	});
	$("#userpass").val($.cookie("userpass"));
	$(document).keypress(function(e) {
	       if(e.which == 13) {
	    	   saveName();
	       }
	});
});

//$('.loginBtn').click(function(e) {
function saveName() {
    var account = $('.account').val();
    var password = $('.password').val();
    if($("#rememberName").prop("checked")){
		$.cookie("userAccount", account, {expires:7});
		$.cookie("userpass", password, {expires:7});
	}
    if(!account) {
        $.toast('账户名不能为空');
        return;
    }
    else if(!password) {
        $.toast('密码不能为空');
        return;
    }
    else{
       	$.ajax({
        	url:"${pageContext.request.contextPath}/api/login/applogin",
        	cache:false,
        	data:{userAccount:$("#userAccount").val(),password:$("#userpass").val()},
        	success:function(data){
        		if(data.result==1){
        			window.location.href="${pageContext.request.contextPath}/app/home";
        		}else{
        			$.toast(data.msg);
        		}
        	}
        });
    }
};


function clearAll() {
	$("#userAccount").val("");
	$("#userpass").val("");
	
};

</script>
</body>
</html>
